package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.entity.bean.SetOutSealCarEntity;

import java.util.List;

/**
 * 出发封车适配器
 *
 * @author 000432
 * @date 2018/6/6 0006
 */

public class SetOutSealCarAdapter extends CommonRecycleAdapter<SetOutSealCarEntity> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public SetOutSealCarAdapter(Context context, List<SetOutSealCarEntity> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_set_out_seal_car);
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;
    }

    @Override
    public void bindData(CommonViewHolder holder, SetOutSealCarEntity data, int position) {
        if (!data.getStowageNo().startsWith("P")) {
            //快递展示车标号
            holder.setText(R.id.tv_stowageNo, data.getCarMark());
        } else {
            holder.setText(R.id.tv_stowageNo, data.getStowageNo());
        }
        holder.setText(R.id.tv_next_station, data.getDestDeptName());
        holder.setText(R.id.tv_carNo, data.getCarNo());
        holder.setCommonClickListener(mCommonClickListener);

        View view = holder.getView(R.id.ll_setOut_sealCar_item);
        view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        TextView tvCarState = holder.getView(R.id.tv_sealCarState);
        // 封车状态:：1-未绑定，2-已绑定，3-解封，4-异常解封-封签遗失，5-异常解封-封签破损，6-异常解封-封签漏扫，7-异常解封-封签错误
        if (data.getSealStatus() == 1) {
            tvCarState.setText("未封车");
        } else if (data.getSealStatus() == 2) {
            tvCarState.setText("已封车");
            view.setBackgroundColor(mContext.getResources().getColor(R.color.green));
        } else if (data.getSealStatus() == 3) {
            tvCarState.setText("解封");
        }
        if (data.isCheck()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
        }
    }
}
